#include <stdio.h>
#include <stdlib.h>

// 函数：将8位字节串转换为整数
unsigned int bytes_to_int(unsigned char* M, int mlen) {
    unsigned int x = 0;
    for (int i = 0; i < mlen; i++) {
        x += (1 << (8 * (mlen - 1 - i))) * M[i];
    }
    return x;
}

int main() {
    // 示例字节串
    unsigned char M[] = {0x12, 0x34};
    int mlen = sizeof(M) / sizeof(M[0]);

    unsigned int x = bytes_to_int(M, mlen);
    printf("转换后的整数: %u\n", x);

    return 0;
}
